package com.kim.rssreader.utils;

import java.util.List;

import android.content.Context;
import android.net.Uri;

import com.google.code.rome.android.repackaged.com.sun.syndication.feed.synd.SyndContentImpl;
import com.google.code.rome.android.repackaged.com.sun.syndication.feed.synd.SyndEntry;

public class ActivityDispatchUtil {

	public static void toContentPage(Context context, SyndEntry syndEntry,
			String columnCategory, String columnFlagStarter,
			String columnFlagEnd, String columnId) {
		String link = syndEntry.getLink();
		/*
		 * Intent intent = new Intent("android.intent.action.VIEW",
		 * Uri.parse(link));
		 */
		@SuppressWarnings("unchecked")
		List<Object> contents = syndEntry.getContents();
		String content = null;
		if (contents != null && contents.size() > 0) {
			Object object = contents.get(0);
			if (object instanceof SyndContentImpl) {
				content = null;
			} else {
				content = (String) contents.get(0);
			}
		}

		// content = entry.getDescription().getValue();
		ActivityDispatch.toContentView(context, Uri.parse(link).toString(),
				syndEntry.getTitle(),
				DateUtil.parseDate2Str(syndEntry.getPublishedDate()),
				columnCategory, columnFlagStarter, columnFlagEnd, columnId,
				content);
	}
}
